//package com.tech.platform.cms.dataTools.redis.aop;
//
//import com.tech.platform.cms.dataTools.redis.annotation.RedisDs;
//import lombok.extern.slf4j.Slf4j;
//import org.aspectj.lang.ProceedingJoinPoint;
//import org.aspectj.lang.annotation.Aspect;
//import org.aspectj.lang.annotation.Pointcut;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.core.annotation.Order;
//import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
//
///**
// * Created by Administrator on 2019/11/28.
// */
//@Aspect
//@Order(-1)
//@Slf4j
//public class DynamicRedisDatabaseAnnotationAdvisor {
//
//    @Value("${spring.redis.database}")
//    private int defaultDatabase;
//
//    @Autowired
//    private JedisConnectionFactory jedisConnectionFactory;
//
//    @Pointcut("@annotation(com.tech.platform.cms.dataTools.redis.annotation.RedisDs)")
//    public void aspect() {
//    }
//
//    public Object interceptor(ProceedingJoinPoint invocation, RedisDs redisDs) throws Throwable{
//        try{
//            String dsValue = redisDs.dataBaseIndex();
//
//        }catch (Exception ex){
//            log.error("[DataTool] 动态切换redis database 出现异常:{}",ex.getMessage(),ex);
//        }finally {
//            resetReidsDatabase();
//            return invocation.proceed();
//        }
//    }
//
//    public void resetReidsDatabase(){
//        jedisConnectionFactory.setDatabase(defaultDatabase);
//    }
//}
